package com.dearbinge.data.service.impl.admin;

import com.dearbinge.data.api.admin.AdminSecurityRoleAuthorityService;
import com.dearbinge.data.dao.admin.AdminSecurityRoleAuthorityMapper;
import com.dearbinge.data.pojo.admin.vo.AdminSecurityRoleAuthorityRequestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色权限接口实现层
 *
 * @author wes
 * @date 2019/4/12
 */
@Service("adminSecurityRoleAuthorityService")
public class AdminSecurityRoleAuthorityServiceImpl implements AdminSecurityRoleAuthorityService {

	@Autowired
	private AdminSecurityRoleAuthorityMapper adminSecurityRoleAuthorityMapper;


	/**
	 * 新增
	 * @param list 请求参数list
	 * @return 影响行数
	 */
	@Override
	public Integer insert(List<AdminSecurityRoleAuthorityRequestVO> list) {
		//删除角色全部权限 再新增
		Integer roleId = list.get(0).getRoleId();
		adminSecurityRoleAuthorityMapper.deleteByRoleId(roleId);
		Integer integer = adminSecurityRoleAuthorityMapper.insertList(list);
		return integer;
	}
}